/**
 * 模拟手机预览
 */
define( [
  'jquery',
  '../collect/editorCollect/subDataCheck',
  '../lib/editData',
  'sendPreview',
  'combiner',
  'bootstrap'
], function( $, sdc, editData, sp, combiner ) {
  'use strict';
  var defaultText = '输入你的文章标题';
  var $editColumn2 = $( '.edit-column>.edit-column2' );
  var titleAuthorSet = {
    titleSet: function() {
      combiner.setData( {
        title: $( this ).val() || defaultText
      } );
    },
    authorSet: function() {
      combiner.setData( {
        author: $( this ).val()
      } );
    }
  }

  $editColumn2.on( {
    change: titleAuthorSet.titleSet,
    keyup: titleAuthorSet.titleSet
  }, '.title-author-div>.article-title-input>.edit-input' ).on( {
    change: titleAuthorSet.authorSet,
    keyup: titleAuthorSet.authorSet
  }, '.title-author-div>.article-author-input>.edit-input' );


  // 发送到手机预览
  combiner.$selector.on( 'click', '#send-to-phone-preview', function() {

    for ( var i in editData.graphDataDetails ) {
      editData.graphDataDetails[ i ][ 'isAllCheck' ] = 2;
    }

    sdc.doSaveGraph( function( groupID, title ) {
      sp.doArtSendPreview( {
        articleGroup: groupID,
        articleTitle: title
      } );
    } );

  } );
} );
